package test

import java.io.File

import org.apache.commons.io.FileUtils

import scala.collection.JavaConverters._

object test2 {


  def main(args: Array[String]): Unit = {

    val sheng =  FileUtils.readLines(new File("E:\\Desktop\\PCD_AllData_V1/sheng_filter.txt")).asScala
    val shi =  FileUtils.readLines(new File("E:\\Desktop\\PCD_AllData_V1/shi_filter.txt")).asScala
    val xian =  FileUtils.readLines(new File("E:\\Desktop\\PCD_AllData_V1/xian_filter.txt")).asScala

    val shengmap = sheng.map{x=>
       val m =x.split("\t")
      (m.head,m.last)
    }.toMap



    val shimap = shi.map{x=>
      val m = x.split("\t")
      (m.head, shengmap(m.last.trim) + "\t" + m(1) )
    }.toMap

    val xianmap = xian.map{x=>
      val m = x.split("\t")
      shimap(m.last.trim) + "\t" + m(1)
    }

    FileUtils.writeLines(new File("E:\\Desktop\\PCD_AllData_V1/filter.txt"),"UTF-8",xianmap.asJava)


  }


  def getFilter = {
    val f = FileUtils.readLines(new File("E:\\Desktop\\PCD_AllData_V1/xian.txt"),"GB2312").asScala

    val shi = f.map(_.split(",")).map{x=>
      val id = x(4).drop(x(4).lastIndexOf("(")+1)
      val s = x(5).drop(3).dropRight(1)
      id + "\t" +s + "\t" + x(6)
    }

    FileUtils.writeLines(new File("E:\\Desktop\\PCD_AllData_V1/xian_filter.txt"),"UTF-8",shi.asJava)
  }
}
